<?php
	include("../Includes/FusionCharts.php");
	include("../Includes/FusionCharts_Gen.php");
	include("../Includes/DBConn.php");
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml">
	<HEAD>
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
		<title>UPLB DV</title>
		
		<script language="Javascript" src="../js/FusionCharts.js"></script>
		<script type="text/javascript" src="../fancybox/jquery.min.js"></script>
		<script type="text/javascript" src="../fancybox/jquery.mousewheel-3.0.4.pack.js"></script>
		<script type="text/javascript" src="../fancybox/jquery.fancybox-1.3.4.pack.js"></script>
		<script type="text/javascript">

		$(document).ready(function() {
			$("a#example1").fancybox();

			$("a#example2").fancybox({
				'overlayShow'	: false,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic'
			});

			$("a#example3").fancybox({
				'transitionIn'	: 'none',
				'transitionOut'	: 'none'	
			});

			$("a#example4").fancybox({
				'opacity'		: true,
				'overlayShow'	: false,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'none'
			});

			$("a#example5").fancybox();

			$("a#example6").fancybox({
				'titlePosition'		: 'outside',
				'overlayColor'		: '#000',
				'overlayOpacity'	: 0.9
			});

			$("a#example7").fancybox({
				'titlePosition'	: 'inside'
			});

			$("a#example8").fancybox({
				'titlePosition'	: 'over'
			});

			$("a[rel=example_group]").fancybox({
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'titlePosition' 	: 'over',
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
				return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
			}
		});

			$("#various1").fancybox({
					'titlePosition'		: 'inside',
					'transitionIn'		: 'none',
					'transitionOut'		: 'none'
			});

			$("#various2").fancybox();

			$("#various3").fancybox({
					'width'				: '75%',
					'height'			: '75%',
					'autoScale'			: false,
					'transitionIn'		: 'elastic',
					'transitionOut'		: 'elastic',
					'type'				: 'iframe'
			});

			$("#various4").fancybox({
					'padding'			: 0,
					'autoScale'			: false,
					'transitionIn'		: 'none',
					'transitionOut'		: 'none'
			});

		});

	</script>

		<link rel="stylesheet" href="../fancybox/jquery.fancybox-1.3.4.css" type="text/css" media="screen" />

	</HEAD>

	<BODY bgcolor="white">
	<CENTER>
			<?php
				$subject = $_GET['subject'];
				//echo $subject;
				if($subject=="default"){
					$courseCode1 = "CMSC 11";
					$courseCode2 = "MATH 17";
					$courseCode3 = "";
					$courseCode4 = "";
					$startAY = 1996;
					$endAY = 2007;
					
				}
				else{
					$courseCode1 = $_POST['courseCode1'];
					$courseCode2 = $_POST['courseCode2'];
					$courseCode3 = $_POST['courseCode3'];
					$courseCode4 = $_POST['courseCode4'];
					$startAY = $_POST['startAY'];
					$endAY = $_POST['endAY'];
				}
					
				// Connect to the DB				
				$link = connectToDB();

				# Create Multiseries Column3D chart object using FusionCharts PHP Class 
				$FC = new FusionCharts("MSLine","850","440");

				# Set the relative path of the swf file
				$FC->setSWFPath("../FusionCharts/");

				# Store chart attributes in a variable 
				$strParam="caption=SUBJECT PASSING RATES; subcaption=Passing Rates (in percent); xAxisName=Academic Year; yAxisName=Passing Rates; yaxismaxvalue=100; decimalPrecision=0; numberSuffix=%";

				# Set chart attributes 
				$FC->setChartParams($strParam);
				$link = connectToDB();
				$year = $startAY;
				
				while($year <= $endAY){
					$FC->addCategory($year);
					$year++;
				}
				
				if($courseCode1!=""){
					$year = $startAY;
					# Create a new dataset 
					$FC->addDataset($courseCode1); 
					while($year <= $endAY){
						$strQuery = "select passingRate from course where courseCode='$courseCode1' and academicYear=$year";
						$result = mysql_query($strQuery) or die(mysql_error());
						$ors = mysql_fetch_array($result);
						$c1 = ($ors['passingRate']);

						# Add chart values for the above dataset
						$FC->addChartData($c1);
						$year++;
					 
					}
					if($courseCode2!=""){
						$year = $startAY;
						# Create second dataset 
						$FC->addDataset($courseCode2); 
						while($year <= $endAY){
							$strQuery = "select passingRate from course where courseCode='$courseCode2' and academicYear=$year";
							$result = mysql_query($strQuery) or die(mysql_error());
							$ors = mysql_fetch_array($result);
							$c2 = ($ors['passingRate']);
						  
							# Add chart values for the above dataset
							$FC->addChartData($c2);
							$year++;
						 
						}
						if($courseCode3!=""){
							$year = $startAY;
							# Create a new dataset 
							$FC->addDataset($courseCode3); 
							while($year <= $endAY){
								$strQuery = "select passingRate from course where courseCode='$courseCode3' and academicYear=$year";
								$result = mysql_query($strQuery) or die(mysql_error());
								$ors = mysql_fetch_array($result);
								$c1 = ($ors['passingRate']);

								# Add chart values for the above dataset
								$FC->addChartData($c1);
								$year++;
							 
							}
							if($courseCode4!=""){
								$year = $startAY;
								# Create second dataset 
								$FC->addDataset($courseCode4); 
								while($year <= $endAY){
									$strQuery = "select passingRate from course where courseCode='$courseCode4' and academicYear=$year";
									$result = mysql_query($strQuery) or die(mysql_error());
									$ors = mysql_fetch_array($result);
									$c2 = ($ors['passingRate']);
								  
									# Add chart values for the above dataset
									$FC->addChartData($c2);
									$year++;
								 
								}
							}
						}
					}
				}
	
				mysql_close($link);
				$FC->renderChart();
								
			?>
	</CENTER>
	</BODY>
</HTML>